<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('用户信息列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>账号：</label>
                                <input type="text" name="account"/>
                            </li>
                            <li>
                                <label>邮箱：</label>
                                <input type="text" name="email"/>
                            </li>

                            <li>
                                <label>手机号：</label>
                                <input type="text" name="mobile"/>
                            </li>
                            <li>
                                <label>用户标识：</label>
                                <input type="text" name="userIdentify"/>
                            </li>
                            <li>
                                <label>昵称：</label>
                                <input type="text" name="nickname"/>
                            </li>
                            <li>
                                <label>姓名：</label>
                                <input type="text" name="name"/>
                            </li>
                            <li>
                                开始时间：
                                <input type="text" class="time-input" placeholder="请选择开始时间" id="startCreateTime" name="startCreateTime" th:value="${#dates.format(startCreateTime, 'yyyy-MM-dd')}"/>
                            </li>
                            <li>
                                截止时间：
                                <input type="text" class="time-input" placeholder="请选择结束时间" id="endCreateTime" name="endCreateTime" th:value="${#dates.format(endCreateTime, 'yyyy-MM-dd')}"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;查询</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="privateReset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="product:user:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
               <!-- <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="product:user:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="product:user:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>-->
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="product:user:export">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table" class="table table-bordered table-hover" style="table-layout:fixed;word-break:break-all;"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('product:user:edit')}]];
        var removeFlag = [[${@permission.hasPermi('product:user:remove')}]];
        var prefix = ctx + "product/user";

        window.onload = function() {
            timeInit();
        }

        function timeInit() {
            var dateEnd = new Date();
            var dateStart = $.common.get7DaysBefore(dateEnd);
            var dateEndStr = $.common.dateFormat(dateEnd, "yyyy-MM-dd");
            var dateStartStr = $.common.dateFormat(dateStart, "yyyy-MM-dd");
            $('#startCreateTime').val(dateStartStr);
            $('#endCreateTime').val(dateEndStr);
        }

        function privateReset() {
            $.form.reset();
            timeInit();
        }

        $(function() {
            timeInit();
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/form",
                updateUrl: prefix + "/form/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "用户信息",
                columns: [{
                    checkbox: false,
                    visible: false
                },
                {
                    field: 'id',
                    title: 'id',
                    width: 60
                },
                {
                    field: 'userIdentify',
                    title: '用户标识',
                    width: 90
                },
                {
                    field: 'headImg',
                    title: '头像',
                    formatter: function(value, row, index) {
                        if (value !="" && value !=null) {
                            return "<img style='width: 50px;height: 50px;' src='" + value + "' />";
                        }
                        return "";
                    },
                    width: 50
                },
                {
                    field: 'account',
                    title: '账号',
                    width: 100
                },
                {
                    field: 'accountCheck',
                    title: '手机号验证状态',
                    formatter: function(value, row, index) {
                        if(value == 1){
                            return "是";
                        }
                        return "否";
                    },
                    width: 120
                },

                {
                    field: 'email',
                    title: '邮箱',
                    width: 100
                },
                {
                    field: 'emailCheck',
                    title: '邮箱验证状态',
                    formatter: function(value, row, index) {
                        if(value == 1){
                            return "是";
                        }
                        return "否";
                    },
                    width: 120
                },
                {
                    field: 'nickname',
                    title: '昵称',
                    width: 120
                },

                {
                    field: 'mobile',
                    title: '手机号',
                    width: 100
                },
                {
                    field: 'name',
                    title: '姓名',
                    width: 120
                },
                {
                    field: 'sex',
                    title: '性别',
                    formatter: function(value, row, index) {
                        if (value == 0) {
                            return "女";
                        } else if (value == 1) {
                            return "男";
                        } else if (value == 2) {
                            return "未知";
                        } else {
                            return "未知";
                        }
                    },
                    width: 50
                },
                {
                    field: 'birthday',
                    title: '出生日期',
                    width: 90
                },
                {
                    field: 'bloodType',
                    title: '血型',
                    width: 60
                },
                {
                    field: 'imsi',
                    title: 'imsi',
                    width: 60
                },
                {
                    field: 'msisdn',
                    title: 'msisdn',
                    width: 60
                },
                {
                    field: 'operator',
                    title: '运营商',
                    width: 90
                },
                {
                    field: 'phoneBrand',
                    title: '手机品牌',
                    width: 90
                },
                {
                    field: 'phoneModel',
                    title: '手机型号',
                    width: 120
                },
                {
                    field: 'firstRegisterApp',
                    title: '首次注册应用',
                    width: 120
                },
                {
                    field: 'productNum',
                    title: '应用数量',
                    formatter: function(value, row, index) {
                        if (value != null) {
                            return '<a href="javascript:void(0)" onclick="productList(\'' + row.id + '\')">' + value + '</a>';
                        }
                    },
                    width: 90
                },
                {
                    field: 'isBlacklist',
                    title: '是否黑名单',
                    width: 90
                },

                {
                    field: 'provinceCode',
                    title: '省',
                    width: 90
                },
                {
                    field: 'cityCode',
                    title: '市',
                    width: 90
                },
                {
                    field: 'countyCode',
                    title: '县',
                    width: 90
                },
                {
                    field: 'address',
                    title: '地址',
                    width: 90
                },
                {
                    field: 'registerTime',
                    title: '注册时间',
                    width: 90
                },

                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="viewThirdBind(\'' + row.id + '\')"><i class="fa fa-edit"></i>三方绑定</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a>');
                        return actions.join('');
                    },
                    width: 200
                }]
            };
            $.table.init(options);
        });


        function viewThirdBind(id) {
            $.modal.open("查看用户三方绑定信息",prefix + "/viewThirdBind/"+id);
        }
        function productList(id) {
            $.modal.open("已安装应用名称列表",prefix + "/productList/"+id);
        }
    </script>
</body>
</html>